#include "IGame.h"
#include "StateManager.h"
#include "..\Platform\PlatformFactory.h"

FWint IGame::Init(FWuint id, FWuint iWidth, FWuint iHeight, char * szTitle, FWuint iFlags)
{
	_iWidth = iWidth;
	_iHeight = iHeight;
	FWint err = 0;
	err += PlatformFactory::GetInstance()->CreatePlatform(id, iWidth, iHeight, szTitle, iFlags)->Init();
	PlatformFactory::GetInstance()->GetCurrentPlatform()->RegisterGame(this);
	return err;
}

void IGame::Destroy()
{
	SAFE_DEL(MessageServer::Instance);
	PlatformFactory::DestroyInstance();
	StateManager::DestroyInstance();
}

void IGame::Start()
{
	PlatformFactory::GetInstance()->GetCurrentPlatform()->Run();
	m_bIsActived = true;
	m_bIsPaused = false;
}

void IGame::End()
{
	m_bIsActived = false;
	Destroy();
}

void IGame::Pause()
{
	m_bIsPaused = true;
}

void IGame::Resume()
{
	m_bIsPaused = false;
}